<script setup lang="ts">
import { createTextVNode, defineComponent } from 'vue'
import {
  useDialog,
  useLoadingBar,
  useMessage,
  useNotification,
  NLoadingBarProvider,
  NDialogProvider,
  NNotificationProvider,
  NMessageProvider
} from 'naive-ui'

defineOptions({
  name: 'AppProvider'
})

const Context = defineComponent({
  name: 'Context',
  setup() {
    const register = () => {
      window.$loadingBar = useLoadingBar()
      window.$dialog = useDialog()
      window.$message = useMessage()
      window.$notification = useNotification()
    }
    register()
    return () => createTextVNode()
  }
})
</script>

<template>
  <NLoadingBarProvider>
    <NDialogProvider>
      <NNotificationProvider>
        <NMessageProvider>
          <Context />
          <slot name="default"></slot>
        </NMessageProvider>
      </NNotificationProvider>
    </NDialogProvider>
  </NLoadingBarProvider>
</template>

<style scoped></style>
